package com.demo.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * 动态代理类
 * @author Administrator
 *
 */
public class LogProxy implements InvocationHandler {

	/**
	 * 具体执行方法
	 */
	public Object invoke(Object arg0, Method method, Object[] args)
			throws Throwable {
		before();
		//调用目标方法
		Object result=method.invoke(target, args);
		after();
		return result;
	}
	
	//目标对象
	public Object target;
	public LogProxy(Object tObject){
		target =tObject;
	}
	
	public void before(){
		System.out.println("开始写日志");
	}
	public void after(){
		System.out.println("日志写入完成");
	}
	
}
